home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / lang / BCPL4Amiga.lha / tripos / process.doc < prev    next >
Text File  |  1988-12-06  |  3KB  |  64 lines

  1.                                 PROCESS CREATION
  2.  
  3. Author: Bill Kinnersley
  4. Date: Mar 12, 1988
  5. Mail: Physics Dept.
  6.       Montana State University
  7.       Bozeman, MT 59717
  8. BITNET: iphwk@mtsunix1
  9. INTERNET: iphwk%mtsunix1.bitnet@cunyvm.cuny.edu
  10. UUCP: ...psuvax1!mtsunix1.bitnet!iphwk
  11.  
  12.  
  13.         There are several ways of creating a process on the Amiga.
  14.  
  15.         At the lowest level is AddTask(task, initialPC, finalPC),
  16. which adds a given task to the TaskReady list.  Here task is an existing
  17. initialized Task structure, initialPC is the entry point, and finalPC
  18. is an optional cleanup routine.  The final code is pushed on the stack
  19. as if it were the outermost return address.  If finalPC is 0, the system
  20. default cleanup is to call RemTask(), which removes the task from the Ready
  21. list.  It deallocates the MemEntry list, but not the Task structure.  The
  22. task's registers are initially set to 0, except for SP, which is set to
  23. SPReg.  The user may reserve space for initial data by specifying
  24. SPReg < SPUpper.
  25.  
  26.         At the next level is createproc(segarray, stkszlw, pri, ^name, ^gv).
  27. (The internal AmigaDOS function, function 84, at ff4586).  Both NewCLI and
  28. Run call this function.  It:
  29.         Allocates memory for Process structure and stack, and puts this
  30.                 on the MemList
  31.         Fills the Task, Process, and DOS MsgPort:
  32.                 SigWait for signal 8, and default TrapCode = ff4b6a
  33.         Reserves stack space to hold the Process name
  34.         Copies the parent's Console Handler, File Handler, and Window
  35.         AddTask()'s with special initPC and finalPC.
  36.                 The finalPC code frees the SegArray.
  37.                 The initPC code:
  38.         Fills the stack with "tttu", terminating with -1 and SP;
  39.         Sets the BCPL coroutine list to point to SPLower;
  40.         Looks at the Segarray.  If there is more than one entry, it calls
  41.                 GetSegList to fill in the GV;
  42.         It then fills in a5 and a6, waits for a startup packet, and
  43.                 then calls the program code at 4(a2).
  44.  
  45. The external AmigaDOS function CreateProc(*name, pri, seg, stkszb) is
  46. function -48 at ff46bc.  In this case only a seglist is supplied, and
  47. thus the call must create its own SegArray.
  48.         The name buffer is subtracted from the stack request
  49.         20 bytes are AllocMem'ed for the SegArray.
  50.         The GV is obtained from DosLib
  51.         The Task, Process and MsgPort are initialized as above
  52.         The SPReg and ReturnAddr set
  53.         The 1st and 2nd SegList are copied from the parent, the 3rd
  54.                 SegList is the one supplied by caller, but the SegArray
  55.                 length is set to 2
  56.         AddTask() is called, with initPC = 1st SegList, and finalPC the
  57.                 same as above.
  58.  
  59.         The next level is function 1c0 at ff61e0, which calls either
  60. 84 or -48, depending on the flags it is passed.  It is called by no one?
  61.  
  62.         1a0 (at ff5328) is an execute call, which calls -54 at ff53b4
  63. (calls 144, at ff717c, loadseg), then 148 at ff7af0, unloadseg.
  64.